<template>
	<view>
		<view class="header">
			<x-status-bar></x-status-bar>
			<view class="flex-center-between header-navbar">
				<x-back-btn></x-back-btn>
				<view class="u-f-40 font-bold common-title">{{ lang_message.notice }}</view>
			</view>
		</view>

		<view>
			<mescroll-body height="calc(100vh - 98rpx - var(--status-bar-height))" ref="mescrollRef"
				@init="mescrollInit" @down="downCallback" @up="upCallback">
				<view style="padding: 20rpx 20rpx 30rpx;">
					<view v-for="(item, index) in dataList" :key="index" class="card-box u-m-b-20"
						@click="jumpUrl('/pages/other/richText/richText?type=notice&noticeId=' + item.noticeId)">
						<view class="flex-center-between">
							<view class="clear-flex linecamp-1 nowrap" style="width: 440rpx;">
								{{ item.title }}
							</view>

							<view class="u-f-24 u-lh-34 color-grew nowrap clear-flex">{{ formatTime(item.createTime) }}
							</view>
						</view>

						<!-- <view class="u-m-t-4 u-f-28 u-lh-40 color-grew linecamp-1" style="width: 660rpx;">
							{{ item.content }}
						</view> -->
					</view>
					
					<!-- 留空 -->
					<view style="height: 200rpx;"></view>
				</view>
			</mescroll-body>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		noticePage
	} from '@/api/base.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";

	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				dataList: []
			}
		},
		onLoad() {

		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				let node = this.$refs['mescrollRef']
				noticePage({
					pageNumber: page.num,
					pageSize: page.size
				}).then(res => {
					node && node.mescroll.endSuccess(res.list.length);
					if (page.num == 1) this.dataList = []; //如果是第一页需手动制空列表
					this.dataList = this.dataList.concat(res.list); //追加新数据
				}).catch(() => {
					node && node.mescroll.endErr();
				})
			},
			downCallback() {
				let node = this.$refs['mescrollRef']
				node && node.mescroll.resetUpScroll()
			},
		}
	}
</script>

<style lang="scss" scoped>
	.card {
		&-box {
			padding: 20rpx;
			background-color: #F9F9F9;
			border-radius: 14rpx;
		}
	}
</style>
